//
// Created by hamlet on 23-2-25.
//

#ifndef FANSIONML_SOLVER
#define ASSIGNMENT_NLP_SOLVER_H

#include <QString>
#include <QVector>
#include <QMap>

class Solver {
public:
    explicit Solver(const QString &w1, const QString &w2);

    void solve();

    int minDistance() { return distance[word1.size()][word2.size()]; }

    enum class Op {
        INSERTION, DELETION, SUBSTITUTION, NO_CHANGE, UNKNOWN
    };

    void setCost(Op op, int value) { cost[op] = value; }

    struct Point {
        Op op;
        int i, j;
    };

    QList<Point> backtrace();

private:
    QString word1, word2;
    QVector<QVector<int>> distance;
    QVector<QVector<Op>> direction;
    QMap<Op, int> cost;

public:
    const QVector<QVector<int>> &getDistance() { return distance; }

    const QVector<QVector<Op>> &getDirection() { return direction; }

};


#endif //FANSIONML_SOLVER
